/**
 * 内存服务，提供模拟http服务
 */
import { InMemoryDbService } from 'angular-in-memory-web-api';

import { Forms } from '../src/app/pages/forms/class.forms';
import { FormsElementsBase } from '../src/app/pages/forms/class.forms.elements.base';

export class InMemoryDataService implements InMemoryDbService {
    private getType(i: number): string {
        let types = [
            'inputbox',
            'checkbox',
            'radiobox',
            'selectbox'
        ]

        if (i > 3) {
            i = 3;
        }
        return types[i];
    }
    createDb() {
        let forms: Forms, formsNum = 5, i = 0;

        forms = new Forms('block', 'form-title', []);
        for (; i < formsNum; i++) {
            let item: FormsElementsBase<any>;

            item = new FormsElementsBase();
            forms.formElements.push(item);
        }

        return { forms };
    }
}
